
import { Component } from 'react';

const scaleNames = {
  C: "摄氏温度",
  F: "华氏温标",
};

Object.freeze(scaleNames);

class TemperatureInput extends Component {
  constructor(props){
    super(props);
    this.handleChange = this.handleChange.bind(this);
  }
  handleChange(evt){
    this.props.onTemperatureChange(evt.target.value);
  }
  render() {
    const { temperature, scale } = this.props;
    return (
      <fieldset>
        <legend>请输入{scaleNames[scale]}:</legend>
        <input value={temperature} onChange={this.handleChange} />
      </fieldset>
    );
  }
}

export default TemperatureInput ;